Zigzag flattening (ZF) is commonly utilized as a default option to get the image patches ordering in deep models, e.g. vision transformers (ViTs). Notably, when decomposing multi-scale images, ZF could not maintain the invariance of feature point positions.To this end, we investigate the Hilbert flattening (HF) as an alternative for sequence ordering in vision tasks. HF has proven to be superior to other flatten approaches in maintaining spatial locality, when performing multi-scale transformations of dimensional space. In applications, we design a position encoding method based on HF, beating absolute position encoding non-trivially in Transformer architecture. It also can be used to feature down-sampling and feature/image interpolation. Extensive experiments demonstrate that it can yield consistent performance boosts for several popular architectures and applications. The code will be released upon acceptance.
translated by 谷歌翻译